const cloud = require('wx-server-sdk')
const fs = require('fs')
const path = require('path')

cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
})

module.exports = async function ({
    fileName,
}) {
    const fileStream = fs.createReadStream(path.join(__dirname, fileName))
    return await cloud.uploadFile({
        cloudPath: `/music/${fileName}`,
        fileContent: fileStream,
    })
}